import zhCN from "antd/es/locale/zh_CN";
import theme from "@/theme";
import { ConfigProvider as AntdConfigProvider, ConfigProviderProps } from 'antd';
import { PropsWithChildren, useMemo } from "react";
import { merge } from "lodash";

export default function ConfigProvider({ children, ...props }: PropsWithChildren<ConfigProviderProps>){

  const finalProps = useMemo(()=>{
    return merge({
      locale: zhCN,
      theme: {
        token: {
          colorPrimary: theme.primary
        }
      }
    }, props)
  },[props])

  return  <AntdConfigProvider
    {...finalProps}
  >
    {children}
  </AntdConfigProvider>
}
